package org.mikhaylov.cp.service.command;

import java.util.Map;
import java.util.TreeMap;

import org.mikhaylov.cp.service.command.impl.AddInventoryServiceSommand;
import org.mikhaylov.cp.service.command.impl.GetCitiesServiceCommand;
import org.mikhaylov.cp.service.command.impl.GetInventoriesServiceCommand;
import org.mikhaylov.cp.service.command.impl.GetRegionsServiceCommand;
import org.mikhaylov.cp.service.command.impl.GetUserInventoriesServiceCommand;
import org.mikhaylov.cp.service.command.impl.LoginServiceCommand;
import org.mikhaylov.cp.service.command.impl.NoServiceCommand;
import org.mikhaylov.cp.service.command.impl.RefillServiceCommand;
import org.mikhaylov.cp.service.command.impl.RegisterServiceCommand;
import org.mikhaylov.cp.service.command.impl.UpdateProfileServiceCommand;

public class ServiceCommandContainer {

	private static Map<String, ServiceCommand> commands = new TreeMap<String, ServiceCommand>();

	static {
		commands.put("noCommand", new NoServiceCommand());

		commands.put("login", new LoginServiceCommand());
		commands.put("register", new RegisterServiceCommand());
		commands.put("addInventory", new AddInventoryServiceSommand());
		commands.put("refill", new RefillServiceCommand());
		commands.put("updateProfile", new UpdateProfileServiceCommand());

		commands.put("getRegions", new GetRegionsServiceCommand());
		commands.put("getCities", new GetCitiesServiceCommand());
		commands.put("getInventories", new GetInventoriesServiceCommand());
		commands.put("getUserInventories",
				new GetUserInventoriesServiceCommand());
	}

	public static ServiceCommand get(String commandName) {
		if (commandName == null || !commands.containsKey(commandName)) {
			return commands.get("noCommand");
		}

		return commands.get(commandName);
	}

}
